<?php

class Ngo extends Datamapper {
    
	var $db_params = 'ngo';
	var $table = 'ngos';
	var $auto_populate_has_many = TRUE;
	var $auto_populate_has_one = TRUE;
	
	var $has_many = array(
		'contacts' => array(			
			'class' => 'ngo_contact',
			'other_field' => 'ngo',
			'join_self_as' => 'ngo',
			'join_other_as' => 'contact',
			'join_table' => 'r_contacts_ngos'),
		'projects' => array(			
			'class' => 'ngo_project',
			'other_field' => 'ngo',
			'join_self_as' => 'ngo',
			'join_other_as' => 'project',
			'join_table' => 'r_ngos_projects'),
		'accounts' => array(
			'class' => 'ngo_account',
			'other_field' => 'ngo',
			'join_self_as' => 'ngo',
			'join_other_as' => 'account',
			'join_table' => 'r_accounts_ngos'),
		'images' => array(
			'class' => 'ngo_image',
			'other_field' => 'ngo',
			'join_self_as' => 'ngo',
			'join_other_as' => 'image',
			'join_table' => 'r_images_ngos'),
		'zones' => array(
			'class' => 'zone',
			'other_field' => 'ngos',
			'join_self_as' => 'ngo',
			'join_other_as' => 'zone',
			'join_table' => 'r_ngos_zones'),
		'causes' => array(
			'class' => 'cause',
			'other_field' => 'ngos',
			'join_self_as' => 'ngo',
			'join_other_as' => 'cause',
			'join_table' => 'r_causes_ngos'),
	);
	
	function get_ngo_country() {
		$c = new Country();
		$q = $c->get_by_id($this->country_id);
		
		if (count($q) == 1) return $q;
		return NULL;
	}
}

/* End of file country.php */
/* Location: ./application/models/country.php */